package com.packageclass;

/**
 * @Author WaveHi
 * @Date 7/8/2021 下午 4:06
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description 使用包装类
 */
public class Test1 {

    public static void main(String[] args) {

        //获取包装类对象

        Integer i1 = Integer.valueOf(30);
        Integer i2 = Integer.valueOf("30");


        //包装类转字符串
        String s1 = i1.toString();
        String s2 = Integer.toString(i2);

        //String -> int
        int i3 = Integer.parseInt(s1);

        //装箱
        Integer i5 = Integer.valueOf(10);

        //拆箱
        int i6 = i5.intValue();

        //自动装箱
        Integer i7 =  20;


        //自动拆箱
        int i8 = i7;

        //测试Integer类的缓存设计
        Integer integer1 = Integer.valueOf(10);
        Integer integer2 = 10;
        System.out.println(integer1 == integer2);
        Integer integer3 = Integer.valueOf(129);
        Integer integer4 = 129;
        System.out.println(integer3 == integer4);


    }

}
